<html>
<HEAD>
  <link rel="shortcut icon" type="image/png" href="/css/py.png" /> 
  <link rel="stylesheet" href="/peer.css" />
  <link rel="stylesheet" href="/css/cdna.css" />
  <title> Peer </title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>  
  <script src="/js/cdna.js"></script>
  <script src="/peer.js"></script>    
</HEAD>
<body>
  <div id=body>
  <div class=header> Peer Control Panel </div>
  <table class=control-buttons>
  <tr><td>
    <form class=reset><input class=submitForm type=button value="reset peer"><input type=hidden name=method value=reset></form>
  </td><td>  
    <form class=stop><input id=stopAll class=submitForm type=button value="stop everything"><input type=hidden name=method value=stop></form>
  </td></tr>
  </table>
  
  <div id=left>
    <fieldset>
    <legend class=collapsed> Peer Settings & Status </legend>
      <form action="/" method="POST">      
      <input type="hidden" name=method value=save_settings>
      <input type="button" value="save" class="submitForm">
      <table>                                       
        <tr><td> id: </td> <td><span id="peer-id"></span> </td> </tr>
        <tr> <td>name : </td> <td> <span id="peer-name"></span></td> </tr> 
        <tr> <td>recipe_server_status : </td><td> <span id="peer-recipe_server_status"></span></td><tr>
        <tr> <td> tracker_status : </td><td> <span id="peer-tracker_status" > </span></td></tr> 
        <tr> <td>rpc_host : </td><td> <span id="peer-rpc_host"> </span></td></tr>
        <tr> <td>rpc_port : </td><td> <span id="peer-rpc_port" > </span></td></tr>         
        <tr> <td>num_unsent_blocks : </td><td> <span id="peer-num_unsent_blocks"></span></td></tr>         
        <tr> <td>recipe_server_host</td> 
             <td><input type=text name=recipe_server_host>
                 current: <span id=peer-recipe_server_host></span></td>
        </tr> 
        <tr>
        <td>recipe_server.port: </td>
        <td> <input type=text  name=recipe_server_port> 
            current: <span id="peer-recipe_server_port"></td>
        </tr>
        <tr>
            <td> tracker.host : </td>
            <td> <input type=text  name=tracker_host>
            current: <span id="peer-tracker_host"></span></td>
        </tr> 
        <tr>  <td>tracker.port: </td>
              <td> <input type=text  name=tracker_port>
              current:<span id="peer-tracker_port"></span></td>
        </tr>
        <tr>
          <td> external_ip: </td>
          <td> <input  type=text  name=external_ip>
          current: <span id="peer-external_ip"> </span></td>
        </tr> 
        <tr>
          <td>external_port : </td>
          <td> <input type=text  name=external_port>
          current: <span id="peer-external_port"></span></td>
          
        </tr>
      </table>
      </form>
    </fieldset>
    <fieldset class="fieldset">
      <legend> Share A File! </legend>
      <form action="/" method="post" enctype="multipart/form-data">
        <input type="hidden" name="method" value="share_file">
        <input size=100 type="button" value="share" class="submitForm">
        <table>
          <tr>
            <td><label>Select file to share: </label></td>
            <td><select name=fileind onchange="fileinputchanged($(this).children()[this.value].text);"></select> </td>
          </tr>
          <tr>
            <td><label>shared file name:</label></td>
            <td><input id=filename name=filename type=text></td>            
          </tr>
        </table>
      </form>
    </fieldset>
    
    <fieldset class="fieldset">
      <legend> Search on Recipe Server </legend>      
          <form action="/" method="POST">
            <input type=button value=search class="submitForm">
            <input type="hidden" name=method value="search_rs">
            <input style="width:50%;" name="query"  type="text" size=50>
          </form>
          <hr style="width:50%;"/>        
          <form action="/" method="post">
            <input type="button" value="download" class="submitForm">  
            <select style="width:50%;" name="file_id"> </select>            
            <input type="hidden" name="method" value="download_from_rs">          
          </form>                
    </fieldset>
    <fieldset>    
      <legend> Downloaded/Shared Files </legend>
      <input type=button class=refreshFiles value=refresh>
      <iframe src="shared" id=shared-files style="float:left; width:85%;"></iframe>      
      <form>
      <input type=hidden name=method value=delete_all>
      <input type=button value="delete all" class=submitForm>
      </form>
    </fieldset>
  </div> <!-- end of left -->
  <div id=right>
    <fieldset class="fieldset">
      <legend> Recipes in Local Database </legend>
      <table border=1 style="width:100%" id=recipes_table>
        <tr>
          <th> id </th> <th> name </th> <th> size </th> <th> # blocks </th> <th> sent to rs? </th>
        </tr>

      </table>
    </fieldset>
    <fieldset>
      <legend> Run A SQL Query</legend>
      <form>
        <input type=hidden name=method value=run_sql>
        
        <input type=text style="width:100%;" name=query>
        <input class=submitForm type=button value=submit>
      </form>
      <div id=sql-results>
      </div>
    </fieldset>
        <fieldset>
      <legend> Recipe Creation Queue </legend>
      <table border=1 style = "width:100%" id=rq_table>
      <tr>
        <th> fileid </th> <th> filename </th> <th> size </th> <th> processed </th>
      </tr>
      </table>
    </fieldset>
    <fieldset>
      <legend> Recipe Download Queue </legend>
      <table border=1 style = "width:100%" id=rdq_table>
      <tr>
        <th> fileid </th> <th> filename </th> <th> number of blocks </th> <th> remaining # blocks</th>  
      </tr>
      </table>
    </fieldset>
    <fieldset>
      <legend> File Construction Queue </legend>
      <table border=1 style = "width:100%" id=fcq_table>
      <tr>
        <th> fileid </th> <th> filename </th> <th> number of blocks remaining </th>   
      </tr>
      </table>
    </fieldset>
    
  </div>
  </div>
  <div class="footer"> 2010-2010 All rights belong to CDNA </div>
</body>
</html>